package com.zdb.java.collection;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class ListTest {

    /**
     * 不可变list, 重写set,add方法，直接抛出UnsupportedOperationException
     */
    @Test
    public void testUnmodify() {

        List<String> list = Collections.unmodifiableList(new ArrayList<>());

        list.add("aa");
        System.out.println(list.size());
    }
}
